package com.clouddot.baipai.ui.adapter.V_Adapter;


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.clouddot.baipai.R;
import com.clouddot.baipai.model.beam.getClassMemberById.studentInfo;

import java.util.List;

/**
 * Created by wxy on 2018/3/29.
 */

public class V_classMemberRecyclerAdapter extends RecyclerView.Adapter<V_classMemberRecyclerAdapter.MyViewHolder> {
    private Context context;
    private List<studentInfo> list;
    public V_classMemberRecyclerAdapter(Context context, List<studentInfo> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
                context).inflate(R.layout.v_l_memberadapteritem, parent,
                false));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        holder.tv1.setText(list.get(position).getFullName());
//        holder.tv2.setText(list.get(position).getSexText());
        if(list.get(position).getSexText().equals("男")){
            holder.imageView.setBackgroundResource(R.drawable.manicon);
        }else if(list.get(position).getSexText().equals("女")){
            holder.imageView.setBackgroundResource(R.drawable.womanicon);
        }else{
            holder.imageView.setBackgroundResource(R.drawable.penson);
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView tv1 ,tv2;
        private ImageView imageView;

        public MyViewHolder(View view) {
            super(view);
            tv1 = view.findViewById(R.id.tv1);
//            tv2 = view.findViewById(R.id.tv2);
            imageView = view.findViewById(R.id.image);

        }
    }
    public interface btnOnclicker {
        void onClicked(int position);
    }

    private  btnOnclicker btnclicker;

    public void setbtnOnclicker(btnOnclicker btnclicker) {
        this.btnclicker = btnclicker;
    }

}

